<?php

namespace app\mall\controller\admin;


use suframe\thinkAdmin\traits\CURDController;
use suframe\thinkAdmin\ui\UITable;
use app\mall\model\MallOrderEvaluate as MallOrderEvaluateModel;

/**
 * 发票管理
 */
class MallOrderEvaluate extends Base
{
    use CURDController;
    protected $urlPre = '/mall/admin/mallOrderEvaluate/';

    private function getManageModel()
    {
        return MallOrderEvaluateModel::class;
    }
    /**
     * @param UITable $table
     */
    private function beforeIndexRender($table){
        if ($sn = $this->request->get('sn')){
            $table->setFilter('sn', ['label' => '订单号', 'type' => 'text', 'defaultValue' => $sn]);
        }
    }

    private function ajaxSearch()
    {
        $rs = $this->parseSearchWhere($this->getManageModel(), [
            'create_time' => 'betweenTime',
            'content' => 'like',
            'sn' => 'like',
        ])->append([
            'user_type_text', 'user_name', 'show_text', 'rmd_text'
        ]);
        return json_return($rs);
    }

    /**
     * @param \suframe\form\Form $form
     * @throws \FormBuilder\Exception\FormBuilderException
     * @throws \ReflectionException
     */
    private function getFormSetting($form)
    {
        $form->setRuleByClass(\app\mall\ui\form\MallOrderEvaluateForm::class);
    }

    /**
     * @param UITable $table
     */
    private function getTableSetting($table)
    {
        $table->createByClass(\app\mall\ui\table\MallOrderEvaluateTable::class);
        $table->setEditOps($this->urlA('update'), ['id']);
    }
}